/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-11-19 13:25:08
 * 天凉好个秋
 */
import dotenv from 'dotenv'
dotenv.config()
import dbConnect from './db';
dbConnect()
import koa from 'koa'
import router from './router'
import { Server } from 'http'
import koaBody from 'koa-body';
import accessLogMiddleware from './middleware/accessLogMiddleware'
const app = new koa()

app
.use(koaBody({
    multipart: true,
    formidable: {
        maxFileSize: 6 * 1024 * 1024
    }
}))
.use(accessLogMiddleware)
.use(router.routes())

const run = (port: Number): Server => {
    return app.listen(port)
}
export default run